﻿using B.S.Sterilizationcenter.Domain.zyy;
using B.S.Sterilizationcenter.ErrorCode;
using MediatR;
using SqlSugar;

namespace B.S.Sterilizationcenter.Read.API.Application.Command.DepartmentQuerys
{
    public class GetDepartmentQueryHandler : IRequestHandler<GetDepartmentQueryCommand, ApiResult<List<DepartmentQuery>>>
    {
        private readonly ISqlSugarClient db;

        public GetDepartmentQueryHandler(ISqlSugarClient db)
        {
            this.db = db;
        }

        public  Task<ApiResult<List<DepartmentQuery>>> Handle(GetDepartmentQueryCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<DepartmentQuery>> result = new ApiResult<List<DepartmentQuery>>();
            List<DepartmentQuery> list = db.Queryable<DepartmentQuery>().Where(o => o.IsDelete == false).ToList();
            result.Code = ApiEnums.查询成功;
            result.Msg = "查询成功";
            result.Data = list;
            return Task.FromResult(result);
        }
    }
}
